package edu.ncet.desktop.shared;

import java.util.Map;
import java.util.Set;

import com.extjs.gxt.ui.client.data.BaseModel;

public class AnswerSheetModel extends BaseModel {

	private static final long serialVersionUID = -8096032989227917962L;
	
	public static final String UNANSWERED = "UNANSWERED" ;

	public AnswerSheetModel() {}
	
	@SuppressWarnings("unchecked")
	public Map<Integer,String> getAnswerSheet(){
		return (Map<Integer,String>)get("answerSheet");
	}
	
	public void setAnswerSheet(Map<Integer,String> answerSheet){
		set("answerSheet" , answerSheet);
	}
	
	public void setAnswer(Integer questionNumber, String answer){
		getAnswerSheet().put(questionNumber, answer);
	}
	
	public void setUnanweredQuestions(Integer unansweredQuestionNo)
	{
		getAnswerSheet().put(unansweredQuestionNo, UNANSWERED);
	}
	
	public String getAnswer(Integer questionNumber) {
		for(Integer keyQuestionNum : getAnswerSheet().keySet()) {
			if(keyQuestionNum == questionNumber)
				return getAnswerSheet().get(keyQuestionNum);
		}
		return "";
	}
	
	public Set<Integer> getAvailableAns(){
		return getAnswerSheet().keySet();
	}
	
	public Boolean containsAns(Integer questionNumber) {
		for(Integer keyQuestionNum : getAnswerSheet().keySet()) {
			if(keyQuestionNum == questionNumber)
				return true;
		}
		return false;
	}
}
